package com.tank;

import com.tank.thrift.Person;
import com.tank.thrift.PersonService;
import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/7/10 0010
 * Time: 下午 8:11
 * To change this template use File | Settings | File Templates.
 */
@Slf4j
public class ThriftClient {

    public static void main(String[] args) throws TException {

        TTransport transport = new TFramedTransport(new TSocket("localhost",8899),600);
        TProtocol protocol = new TCompactProtocol(transport);

        PersonService.Client client = new PersonService.Client(protocol);
        transport.open();
        Person hello =  client.getPersonByUsername("hello");

        log.info("person:{}",hello);
    }
}
